<?php

namespace App\Console\Commands;

use App\Jobs\ProcessExpiredRooms;
use Illuminate\Console\Command;

class ProcessExpiredRoomsCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'rooms:process-expired 
                            {--queue : 使用队列处理}
                            {--sync : 同步处理（不使用队列）}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '处理过期的房间';

    /**
     * Execute the console command.
     */
    public function handle(): int
    {
        $useQueue = $this->option('queue') || !$this->option('sync');
        
        if ($useQueue) {
            $this->info('使用队列处理过期房间...');
            ProcessExpiredRooms::dispatch();
            $this->info('过期房间处理任务已加入队列');
        } else {
            $this->info('同步处理过期房间...');
            ProcessExpiredRooms::dispatchSync();
            $this->info('过期房间处理完成');
        }

        return Command::SUCCESS;
    }
}
